<template>
  <video
    ref="bgVideo"
    id="background_video"
    loop
    muted
    :src="videoUrl"
  />
</template>

<script lang="ts">
import { defineComponent, ref, onMounted } from 'vue'

export default defineComponent({
  name: 'VideoBackground',
  async setup () {
    const bgVideo:any = ref(null)
    const videoUrl = 'https://img.cdn.ceart.top/back.mp4'
    // 页面加载时
    onMounted(() => {
      bgVideo.value.play()
    })

    return { bgVideo, videoUrl }
  }
})
</script>

<style lang="sass" scoped>
video
  @apply fixed left-1/2 top-1/2 h-full w-full bg-white object-cover
  transform: translate(-50%, -50%)
</style>
